#ifndef NNNNUT_LOG
#define NNNNUT_LOG
#include<iostream>
#include<cstring>
// #include <string>

/*
 * 自带文件名字和行号的打印
 * 可宏定义DEBUG以打开关闭
 */
const char* short_file(const char full_path[]) {
    static char search_char = 'x';
    const char* ret;
    if (search_char == 'x') { // 第一次调用，判断输入的路径用的是正斜杠还是反斜杠
        const char* forwardSlash = strrchr(full_path, '/');
        const char* BackSlash    = strrchr(full_path, '\\');
        if( forwardSlash != NULL && BackSlash == NULL ) {
            search_char = '/';
            ret = forwardSlash;
        }
        else if( forwardSlash == NULL && BackSlash != NULL ) {
            search_char = '\\';
            ret = BackSlash;
        }
        else {
            return full_path;
        }
    }
    else {
        if( (ret = strrchr(full_path, search_char)) == NULL) {
            ret = full_path;
        }
    }

    return ret+1;
}
#ifdef DEBUG
    #define SHORT_FILE short_file(__FILE__)

    #define LOG(__fmt__, ...) printf("[Nnnut] %s:%s()%d --- " __fmt__ "\n", SHORT_FILE, __FUNCTION__, __LINE__, ##__VA_ARGS__)

#else

    #define LOG(__fmt__, ...) //啥也不做

#endif //DEBUG
#endif //NNNNUT_LOG
